import { Tools } from 'weaver-mobile';
import * as EmailUtil from '../util/index';
const { catchPostApiError, catchApiError } = EmailUtil.EmailConstant;

export default {
  getRight: params =>
    Tools.callApi({ url: '/api/email/view/hasMailViewRights', method: 'GET', params }).then(catchApiError),
  getBase: params =>
    Tools.callApi({ url: '/api/email/view/mailView', method: 'GET', params }).then(catchApiError),
  getDropDown: params =>
    Tools.callApi({ url: '/api/email/view/getViewPageDropDownByMobile', method: 'GET', params }).then(catchApiError),
  getContent: params =>
    Tools.callApi({ url: '/api/email/view/mailContentView', method: 'GET', params }).then(catchApiError),
  getSentTo: params =>
    Tools.callApi({ url: '/api/email/view/getAllSendTo', method: 'GET', params }).then(catchApiError),
  getReadCount: params =>
    Tools.callApi({ url: '/api/email/view/mailReadCount', method: 'GET', params }).then(catchApiError),
  getReadList: params =>
    Tools.callApi({ url: '/api/email/view/mailReadList', method: 'GET', params }).then(catchApiError),
  doFastReply: params =>
    Tools.callApi({ url: '/api/email/view/fastReply', method: 'GET', params }).then(catchApiError),
  getSendApartResultList: params =>
    Tools.callApi({ url: '/api/email/view/sendApartResultList', method: 'GET', params }).then(catchApiError),
  // 获取用户个人配置信息
  getUserMailSetting: params => 
    Tools.callApi({ url: '/api/email/setting/getUserMailSetting', method: 'GET', params }).then(catchApiError),
  // 标星
  setStar: params => 
    Tools.callApi({ url: '/api/email/base/setStar', method: 'GET', params }).then(catchPostApiError),
  // 导出为 客户联系记录
  crmContactRecord: params =>
    Tools.callApi({ url: '/api/email/export/crmContactRecord', method: 'GET', params }),
  // 导出为文档
  docs: params =>
    Tools.callApi({ url: '/api/email/export/docs', method: 'GET', params }),
  // 删除 和 永久删除
  deleteEmail: params => 
    Tools.callApi({ url: '/api/email/base/deleteEmail', method: 'GET', params }).then(catchPostApiError),
  // 撤回
  recall: params => 
    Tools.callApi({ url: '/api/email/view/recall', method: 'POST', params }).then(catchPostApiError),
  // 操作用户个人文件夹管理（新建，编辑，删除，清空，新建文件夹并移动邮件为.....，移动到文件夹）
  operateUserMailFolder: params => 
    Tools.callApi({ url: '/api/email/setting/operateUserMailFolder', method: 'POST', params }).then(catchPostApiError),
  // 设为完成
  completeWaitdeal: params =>
    Tools.callApi({ url: '/api/email/waitdeal/completeWaitdeal', method: 'GET', params }).then(catchPostApiError),
  // 标记为 
  markEmailToByMobile: params =>
    Tools.callApi({ url: '/api/email/view/markEmailToByMobile', method: 'POST', params }).then(catchPostApiError),
  // 回执 
  EmailCommonOperation: params =>
    Tools.callApi({ url: '/api/email/base/EmailCommonOperation', method: 'POST', params }).then(catchPostApiError),
  // 邮件识别发票
  emailIdentifyInvoice: params => 
  Tools.callApi({ url: '/api/email/base/emailIdentifyInvoice', method: 'POST', params }).then(catchPostApiError),
};